﻿<template>
    <full-screen-dialog
        :title="titleMap[mode]"
        v-model="visible"
        :width="1000"
        destroy-on-close
        @closed="$emit('closed')"
    >
        <el-form
            :model="entityObj"
            :rules="rules"
            :disabled="mode == 'Show'"
            ref="dialogForm"
            label-width="100px"
        >
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="任务组：" prop="jobGroup">
                        <el-input v-model="entityObj.jobGroup" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="名称：" prop="name">
                        <el-input v-model="entityObj.name" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="程序集：" prop="assemblyName">
                        <el-input v-model="entityObj.assemblyName" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="类名：" prop="className">
                        <el-input v-model="entityObj.className" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="任务类型：" prop="triggerType">
                        <el-radio-group v-model="entityObj.triggerType">
								<el-radio-button label="0">间隔</el-radio-button>
								<el-radio-button label="1">Cron</el-radio-button>
							</el-radio-group>
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="Cron：" prop="cron">
                        <el-input v-model="entityObj.cron" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="间隔时间(秒)：" prop="intervalSecond">
                        <el-input v-model="entityObj.intervalSecond" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="启动参数：" prop="jobParams">
                        <el-input v-model="entityObj.jobParams" />
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="开始时间：" prop="beginTime">
                        <el-date-picker type="datetime" v-model="entityObj.beginTime" style="width:300px" placeholder="请选择开始时间"/>- 
                        <el-date-picker type="datetime" v-model="entityObj.endTime" style="width:300px" placeholder="请选择结束时间"/>
                    </el-form-item>
                   
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="是否启动：" prop="isStart">
                        <el-radio-group v-model="entityObj.isStart">
								<el-radio-button label="false">否</el-radio-button>
								<el-radio-button label="true">是</el-radio-button>
							</el-radio-group>
                    </el-form-item>
                </el-col>
               
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item label-width="120px" label="备注">
                        <el-input v-model="entityObj.remark" type="textarea" :rows="2" />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <template #footer>
            <el-button @click="visible = false">取 消</el-button>
            <el-button
                v-if="mode != 'Show'"
                type="primary"
                :loading="isSaveing"
                @click="submit()"
            >保 存</el-button>
        </template>
    </full-screen-dialog>
</template>

<script>
import tool from "@/utils/tool";
export default {
    emits: ["success", "closed"],
    data() {
        return {
            mode: "Add",
            titleMap: {
                Add: "新增",
                Edit: "编辑",
                Show: "查看",
            },
            entityObj: {
                status: 1,
            },
            visible: false,
            isSaveing: false,
            needSaveFlag: false,
            //验证规则
            rules: {
                name: [
                    {
                        required: true,
                        type: "string",
                        message: "请填写名称",
                    },
                ],
                assemblyName:[
                    {
                        required: true,
                        type: "string",
                        message: "请填写程序集名称",
                    },
                ],
                className:[
                    {
                        required: true,
                        type: "string",
                        message: "请填写类名",
                    },
                ],
               
            },
            optionsStoreType: [],
            optionsPaymentType: [],
            optionsInvoicingType: [],
            areaTree:[],
            purchaseDept:[],
            optionsBrand:[]
        };
    },
    methods: {
        //显示=
        open(mode = "Add") {
            this.mode = mode;
            this.visible = true;
            return this;
        },
        //表单提交方法
        submit() {
            this.$refs.dialogForm.validate(async (valid) => {
                if (valid) {
                    this.isSaveing = true;
                    const data={ 
                        ...this.entityObj
                    }
                    try {
                        var returnValue =
                            await this.$API.auth.PostProcessApi.post(
                                this.mode == "Add"
                                    ? "tasksQz/create"
                                    : "tasksQz/update",data
                            );
                        if (returnValue.status == 200) {
                            this.$message.success("操作成功");
                            this.$emit("fatherMethod");
                            this.isSaveing = false;
                            this.visible = false;
                        } else {
                            this.$message.error("操作失败:" + returnValue.msg);
                            this.isSaveing = false;
                            this.visible = false;
                        }
                    } catch (error) {
                        this.loading = false;
                        return false;
                    }
                }
            });
        },
        //表单注入数据
        async setData(data) {
            this.entityObj = {
                ...data
            }; 
        },
        
    },
    async mounted() {
        
    },
};
</script>

<style></style>
